<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src='./template-web.js'>
    </script>

    <script>
        window.onload = function () {
            function success(data) {
                //这里相当于回调函数
                var title = data.title
                var books = data.books
                var tag = '<h1>' + title + '</h1>'
                for (var i = 0; i < books.length; i++) {
                    tag += '<div>' + books[i] + '</div>'
                }
                var con = document.getElementById('container')
                con.innerHTML = tag

            }

            var data = {
                title: '图书信息',
                books: ['三国', '水浒传', '西游记']
            }
            success(data)
        }

    </script>
</head>

<body>
    <div id="container"></div>
</body>

</html>